﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Forecast.Domain.Implementation
{
    class Sell : Offer
    {
        public Sell(IPlay creator, IPredict prediction, int numStocks, int price, DateTime expiryDate) 
            : base(creator, prediction, numStocks, price, expiryDate)
        {
            if (creator.Wallet.AvailableCash < (numStocks * price))
                throw new ApplicationException(
                    String.Format("{0} does not have enough cash to create this offer. "
                    + "{0} only has {1} in cash and the offer would cost {2}.",
                    creator.Name,
                    creator.Wallet.AvailableCash,
                    (numStocks * price)));

            creator.Wallet.SetCashAsideForOffer(numStocks * price);
        }
    }
}
